/* Copyright Thanh-Trung Pham, 2015 */
package jp.ac.uaizu.control;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.ws.WebServiceException;

/**
 * @author Thanh-Trung Pham
 */
@WebService
public interface ISerCompMediator {
    /**
     * Synchronously predict the service reliability.
     *
     * @param translatorName          the name of the used translator.
     * @param generatorName           the name of the used generator.
     * @param configurationSettings   the run configuration settings.
     * @param reliabilityRequirements the service reliability requirements.
     * @param usageProfiles           the usage profiles for the service.
     * @param compositionWorkflow     the composition workflow of the service.
     * @param failureModels           the failure models of external services.
     * @return the binary forms of the presentations of the prediction results.
     * @throws WebServiceException if there is an error.
     */
    @WebMethod
    @WebResult(name = "predictionResults")
    byte[][] predictServiceReliability(@WebParam(name = "translatorName") String translatorName,
                                       @WebParam(name = "generatorName") String generatorName,
                                       @WebParam(name = "runConfigurationSettings") String configurationSettings,
                                       @WebParam(name = "serviceReliabilityRequirements") byte[] reliabilityRequirements,
                                       @WebParam(name = "serviceUsageProfiles") byte[] usageProfiles,
                                       @WebParam(name = "serviceCompositionWorkflow") byte[] compositionWorkflow,
                                       @WebParam(name = "serviceFailureModels") byte[] failureModels) throws WebServiceException;


    /**
     * Asynchronously  predict the service reliability.
     *
     * @param translatorName        the name of the used translator.
     * @param configurationSettings the run configuration settings.
     * @param usageProfiles         the usage profiles for the service.
     * @param compositionWorkflow   the composition workflow of the service.
     * @param failureModels         the failure models of external services.
     * @return the prediction ID for later usages.
     * @throws WebServiceException if there is an error.
     */
    @WebMethod
    @WebResult(name = "predictionID")
    String predictServiceReliabilityAsync(@WebParam(name = "translatorName") String translatorName,
                                          @WebParam(name = "runConfigurationSettings") String configurationSettings,
                                          @WebParam(name = "serviceUsageProfiles") byte[] usageProfiles,
                                          @WebParam(name = "serviceCompositionWorkflow") byte[] compositionWorkflow,
                                          @WebParam(name = "serviceFailureModels") byte[] failureModels) throws WebServiceException;

    /**
     * Get the prediction state.
     *
     * @param predictionID the prediction ID.
     * @return the prediction state which could be one of the following values:
     *          NULL (Invalid prediction ID)
     *          -1 (Unknown state), 0 (Queued state), 1 (Running state), 2 (Completed state).
     */
    @WebMethod
    @WebResult(name = "predictionState")
    Integer getPredictionState(@WebParam(name = "predictionID") String predictionID);

    /**
     * Remove a prediction.
     * @param predictionID the prediction ID.
     */
    @WebMethod
    void removePrediction(@WebParam(name = "predictionID") String predictionID);

    /**
     * Remove all predictions.
     */
    @WebMethod
    void removeAllPredictions();

    /**
     * Get all prediction IDs.
     */
    @WebMethod
    @WebResult(name = "allPredictionIDs")
    String[] getAllPredictionIDs();

    /**
     * Get the prediction feedback.
     * @param predictionID            the prediction ID.
     * @param generatorName           the name of the used generator.
     * @param reliabilityRequirements the service reliability requirements.
     * @return the binary forms of the presentations of the prediction results or an empty array (length =0) if the prediction state is not 2 (Completed state).
     * @throws WebServiceException if there is an error.
     */
    @WebMethod
    @WebResult(name = "predictionResults")
    byte[][] getPredictionFeedback(@WebParam(name = "predictionID") String predictionID, @WebParam(name = "generatorName") String generatorName,
                                       @WebParam(name = "serviceReliabilityRequirements") byte[] reliabilityRequirements) throws WebServiceException;



}
